/*
 * @Author: @miao-xiongmei 2575733397@qq.com
 * @Date: 2022-07-14 17:05:24
 * @LastEditors: @miao-xiongmei 2575733397@qq.com
 * @LastEditTime: 2022-07-26 11:20:24
 * @FilePath: \tainfuhealh\src\router\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE.
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
// import subscribeList from '../views/bookingManagement/subscribeList'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'login',
    meta: { title: '登录'},
    component: () => import('../views/login.vue')
  },
  {
    path: '/home',
    name: 'home',
    meta: { token: true  ,title: '工作台'},
    component: () => import('../views/home.vue'),
    children: [
      {
        path: '/home/',
        component: () => import('../views/workbench/workbench.vue'),
      }
    ]
  },

  // 会员管理
  {
    path: '/memberManage',
    name: 'member',
    meta: { token: true  ,title: '会员管理'},
    component: () => import('../views/home.vue'),
    children: [
      { //会员档案
        path: 'memberManager',
        component: () => import('../views/memberManage/record.vue'),
      },

      {//体检上传
        path: 'memberTestManager',
        component: () => import('../views/memberManage/healthForm.vue'),
      },
      {
        // 会员统计
        path: 'memberStatistic',//未出接口
        component: () => import('../views/memberManage/MemberTable.vue'),
      },

      {
        path: '/memberManage/',
        component: () => import('../views/memberManage/record.vue'),
      },
    ]
  },
  // 预约管理
  {
    path: '/book',
    name: 'Book',
    meta: { token: true  ,title: '预约管理'},
    component: () => import('../views/home.vue'),
    children: [
      {
        path: 'reservationlist',//预约列表
        component: () => import('../views/book/bookList.vue'),
      },
      {
        path: 'appointmentset',//预约设置
        component: () => import('../views/book/bookset.vue'),
      },
      {
        path: 'packagemanagement',//套餐管理
        component: () => import('../views/book/examineSet.vue'),
      },
      {
        path: 'checkitemmanagement',//检查项管理
        component: () => import('../views/book/setMenu.vue'),
      },
      {
        path: '/book/',
        component: () => import('../views/book/bookList.vue'),
      },
    ]
  },
  // 健康评估
  {
    path: '/healthAssessment',
    name: 'Assessment',
    meta: { token: true  ,title: '健康评估'},
    component: () => import('../views/home.vue'),
    children: [
      {
        path: 'physiqueHealth',//体侧 未出
        component: () => import('../views/healthAssessment/side.vue'),
      },
      {
        path: 'psychologicalTests',//心理
        component: () => import('../views/healthAssessment/psychology.vue'),
      },
      {
        path: 'riskAppraisal',//风险
        component: () => import('../views/healthAssessment/risk.vue'),

      },
      {
        path: '/healthAssessment/',
        component: () => import('../views/healthAssessment/side.vue'),
      },
    ]
  },
  // 健康干预
  {
    path: '/healthIntervene',
    name: 'Intervene',
    meta: { token: true  ,title: '健康干预'},
    component: () => import('../views/home.vue'),
    children: [
      {
        path: 'memberClassify',//人群类别
        component: () => import('../views/healthIntervene/classify.vue'),
      },
      {
        path: 'intervene',//干预方案
        component: () => import('../views/healthIntervene/schemes.vue'),
      },
      {
        path: 'visit',//随访日记
        component: () => import('../views/healthIntervene/diary.vue'),
      },
      {
        path: 'pointerManagement',//指标管理
        component: () => import('../views/healthIntervene/indicator.vue'),
      },
      {
        path: 'interveneFormwork',//模板管理
        component: () => import('../views/healthIntervene/template.vue'),
      },
      {
        path: '/healthIntervene/',
        component: () => import('../views/healthIntervene/classify.vue'),
      },
    ]
  },
  // 知识库
  {
    path: '/repository',
    naem: 'repository',
    meta: { token: true  ,title: '知识库'},
    component: () => import('../views/home.vue'),
    children: [
      {
        path: 'evaluation',//评估建议
        component: () => import('../views/repository/suggest.vue'),
      },
      {
        path: 'healthPlan',//健康方案
        component: () => import('../views/repository/precept.vue'),
      },
      {
        path: 'sport',//运懂项目库
        component: () => import('../views/repository/campaign.vue'),
      },
      {
        path: 'meals',//膳食库
        component: () => import('../views/repository/diet.vue'),
      },
      {
        path: 'disease',//疾病库
        component: () => import('../views/repository/illness.vue'),
      },
      {
        path: '/repository/',
        component: () => import('../views/repository/suggest.vue'),
      },
    ]
  },
  // 统计分析
  {
    path:'/statistics',
    name:'  statistics',
    meta: { token: true ,title: '统计分析'},
    component: () => import('../views/home.vue'),
    children: [
      {
        path:"statisticsTanle",
        component: () => import('../views/statistics/table.vue'),
      },
      {
        path:"/statistics/",//工作量统计
        component: () => import('../views/statistics/table.vue'),
      }
    ]
  },
  // 系统设置
  {
    path:'/system',
    name: 'system',
    meta: { token: true,title: '系统设置'},
    component: () => import('../views/home.vue'),
    children: [
      {
        path:"admin",//权限设置
        component: () => import('../views/system/jurisdiction.vue'),
      },
      {
        path:"role",//用户管理
        component: () => import('../views/system/user.vue'),
      },
      {
        path:"questionBank",//题库管理
        component: () => import('../views/system/questionBank.vue'),

      },
      {
        path:"questionnaire",//问卷
        component: () => import('../views/system/questionnaire.vue'),
      },
      {
        path:"/system/",
        component: () => import('../views/system/jurisdiction.vue'),
      },
    ]
  },
  {
    path:'*',
    component: () => import('../views/unknown/404.vue'),
  },
]



const router = new VueRouter({
  routes,
})
router.beforeEach((to, form, next) => {
  if(to.matched.some(rec=>{return rec.meta.token==true})){
    if(sessionStorage.getItem('mytoken')){
      next()
    }else{
      next('/')
    }
  }else{
    next()
  }
  });
  router.afterEach((to, from) => {
    document.title = to.matched[0].meta.title
    
  })


export default router
